<template>
	<view>
		<!--index.wxml-->

		<view class="index">
			<view :class="'header ' + (banertrue ? 'header_lan' : '')" :style="'padding-top: ' + navH + 'px;'">
				<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
					<view class="index_h_cont3">
						<view class="index_wenben baise">{{ $t('page_pintuan.grouping') }}</view>
					</view>
				</view>
				<view class="coloe_title">s</view>
			</view>
			<view class="index_banner" style="position: absolute; background: #fff"><image :src="imgUrl + '/dzx_img68.png'" mode="widthFix"></image></view>

			<view class="index_center" :style="'padding-top:' + (navH + 50) + 'px;padding-bottom: 180rpx;'">
				<view class="pintuan_center">
					<view class="pintuan_item1 xiche_img">
						<swiper
							style="height: 240rpx"
							:indicator-dots="indicatorDots"
							:vertical="vertical"
							:autoplay="autoplay"
							:duration="duration"
							:interval="interval"
							:indicator-color="color"
							:indicator-active-color="colors"
							:circular="circular"
						>
							<swiper-item v-for="(item, index) in bannerList" :key="index">
								<image
									@tap="bannertiaozhuan"
									:src="item.image.file_path"
									:data-type="item.redirect_type"
									:data-url="item.url"
									class="slide-image"
									mode="aspectFill"
								/>
							</swiper-item>
						</swiper>
					</view>
					<view class="pintuan_item2">
						<view class="pintuan_item2_list">
							<view class="pintuan_item2_cont" @tap="goSharingCenter">
								<image :src="imgUrl + '/dzx_img70.png'"></image>
								<text>{{ $t('page_pintuan.puzzle_Plaza') }}</text>
							</view>
							<view class="pintuan_item2_cont" @tap="goCreate">
								<image :src="imgUrl + '/dzx_img71.png'"></image>
								<text>{{ $t('page_pintuan.Start_group') }}</text>
							</view>
							<view class="pintuan_item2_cont" @tap="mySharing">
								<image :src="imgUrl + '/dzx_img72.png'"></image>
								<text>{{ $t('page_pintuan.My_group') }}</text>
							</view>
							<view class="pintuan_item2_cont" @tap="goSharingNear">
								<image :src="imgUrl + '/dzx_img73.png'"></image>
								<text>{{ is_sharp == 1 ? $t('page_pintuan.Head_center') : $t('page_pintuan.apply_for_team_leader') }}</text>
							</view>
						</view>
					</view>
					<!-- <view class="pintuan_item3">
                        <view class="pintuan_item3_l">
                            <image :src="imgUrl+'/dzx_img74.png'"></image>
                            <text>自动定位：{{guojianame}}</text>
                        </view>
                        <view class="pintuan_item3_r" @tap="swichCountry">
                            <text>切换到其他城市</text>
                            <image :src="imgUrl+'/dzx_img75.png'"></image>
                        </view>
                    </view> -->
					<view class="pintuan_item6" v-if="!list">
						<image :src="imgUrl + '/dzx_img77.png'"></image>
						<text>{{ $t('page_pintuan.hint') }}</text>
						<view class="pintuan_item6_btns" @tap="qutianjia">{{ $t('page_pintuan.go_to_add') }}</view>
					</view>
					<view class="pintuan_item4" v-if="list">
						<view class="pintuan_item4_title_banner">
							<view class="pintuan_item4_title">
								<image :src="imgUrl + '/dzx_img47.png'"></image>
								<text>{{ $t('page_pintuan.recommend') }}</text>
							</view>
						</view>

						<view class="pintuan_item4_list">
							<view class="pintuan_item4_cont" :data-id="item.order_id" @tap="goDetail" v-for="(item, index) in list">
								<view class="pintuan_item4_top">
									<view class="pintuan_item4_l">
										<image :src="imgUrl + '/dzx_img27.png'"></image>
										<text>{{ item['title'] }}</text>
									</view>
									<!--       <view class="pintuan_item4_r">
                <image :src="imgUrl+'/dzx_img76.png'"></image>
                <text>{{item['distance']}}KM</text>
              </view> -->
								</view>
								<view class="pintuan_item4_cent" style="margin-top: 24rpx">
									{{ $t('page_pintuan.Group_size') }}
									<text>{{ item['max_people'] }}{{ $t('page_pintuan.rentuan') }}</text>
								</view>
								<view class="pintuan_item4_cent">
									{{ $t('page_pintuan.Shipping_weight') }}
									<text>{{ item['min_weight'] }}KG</text>
								</view>
								<view class="pintuan_item4_cent">
									{{ $t('page_pintuan.Opening_time') }}
									<text>{{ item['start_time'] }}</text>
								</view>
								<view class="pintuan_item4_cent">
									{{ $t('page_pintuan.End_time') }}
									<text>{{ item['end_time'] }}</text>
								</view>
								<view class="pintuan_item4_cent">
									{{ $t('page_pintuan.Receiving_address') }}
									<text>{{ item['address']['country'] }}-{{ item['address']['province'] }}-{{ item['address']['detail'] }}</text>
								</view>
								<view class="pintuan_item4_bottom">
									<view class="pintuan_item4_b1">
										{{ $t('page_pintuan.haicha') }}
										<text>{{ item['remain_weight'] }}</text>
										kg{{ $t('page_pintuan.spell') }}
									</view>
									<view class="pintuan_item4_btns">{{ item['status']['text'] }}</view>
								</view>
							</view>
						</view>
					</view>
					<view class="pintuan_item5" v-if="end">{{ $t('page_pintuan.no_data') }}</view>
				</view>
			</view>
		</view>
		<tabbar :showmenu="menu_type" current="5"></tabbar>
	</view>
</template>

<script>
// pages/shouye/shouye_zkc/shouye_zkc.js
const app = getApp();
let request = require('../../utils/require');
import tabbar from '@/components/tabbar/tabbar.vue';
export default {
	components: {
		tabbar
	},
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData.top,
			imgUrl: app.globalData.imgUrl,
			indexId: 3,
			end:'',
			menu_type: uni.getStorageSync('menu_type'),
			item: {
				indexId: 3,
				colors: '#fff;',
				isfujin: '',
				isshop: ''
			},
			//轮播图
			circular: true,
			//是否显示画板指示点
			indicatorDots: false,
			//选中点的颜色
			colors: '#5D59EC',
			//未选中点的颜色
			color: '#fff',
			//是否竖直
			vertical: false,
			//是否自动切换
			autoplay: true,
			//自动切换的间隔
			interval: 3000,
			//滑动动画时长毫秒
			duration: 1000,
			//默认
			current: 0,
			banertrue: false,
			country_id: 1,
			list: '',
			tankuangisshows: false,
			bannerList: [],
			islogin: false,
			is_sharp: false,
			userarr: []
		};
	}, //滑动显示顶部
	onPageScroll: function(e) {
		if (e.scrollTop > this.navH + 50) {
			this.banertrue= true
		} else {
			this.banertrue= false
		}
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad() {
		var that = this;
		that.getBanner();
		that.switchFun();
	},
	onShow() {
		var that = this;
		let pages = getCurrentPages();
		let currPage = pages[pages.length - 1];
		that.getSharing();
		that.gerenxinxi();
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {
		return {
			title: uni.getStorageSync('setting').desc,
			path: '/pages/index/index?user=' + this.user,
			imageUrl: '',
			success: function(res) {
				console.log('success22:' + JSON.stringify(res));
			},
			fail: function(err) {
				console.log('fail22:' + JSON.stringify(err));
			}
		};
	},
	methods: {
		tiaozhuan(e) {
			uni.navigateTo({
				url: e.currentTarget.dataset.url
			});
		},
		goSharingCenter() {
			uni.navigateTo({
				url: '/pages/sharing/sharing_order_center'
			});
		},
		goSharingNear() {
			var that = this;
			console.log(that.is_sharp);
			if (that.is_sharp == 0) {
				uni.navigateTo({
					url: '/pages/sharing/user'
				});
			} else {
				uni.navigateTo({
					url: '/pages/mys/my_sharp/my_sharp'
				});
			}
		},
		//功能开关
		switchFun() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token')
			};
			request.post(`index.php?s=/api/page/service&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					that.switchFunlist= res.data.data.values
					that.menu_type= res.data.data.values.menu_type
					uni.setStorageSync('service_phone', res.data.data.values.service_phone);
					uni.setStorageSync('menu_type', res.data.data.values.menu_type);
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
				console.log(that.switchFunlist, 777);
			});
		},
		gerenxinxi() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token')
			};
			request.get(`index.php?s=/api/user/detail&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					console.log(res, 're????');
					that.is_sharp= res.data.data.userInfo.is_sharp
					that.userarr= res.data.data.userInfo
					that.islogin= true
				}
			});
			request.get(`index.php?s=/api/user/role&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					that.yonghujuese= res.data.data.userRole
					console.log(res, 'xinxi');
				}
			});
		},
		goCreate() {
			var that = this;
			if (that.is_sharp == 0) {
				uni.navigateTo({
					url: '../sharing/user'
				});
			} else {
				uni.navigateTo({
					url: '../sharing/create'
				});
			}
		},
		goDetail(e) {
			console.log(e, 'e');
			uni.navigateTo({
				url: '/pages/sharing/sharing_order_detail_join?order_id=' + e.currentTarget.dataset.id
			});
		},
		mySharing() {
			uni.navigateTo({
				url: '/pages/sharing/sharing_order'
			});
		},
		swichCountry() {
			uni.navigateTo({
				url: '/pages/indexs/baoguoyg_guojia/baoguoyg_guojia'
			});
		},
		qutianjia() {
			uni.navigateTo({
				url: '/pages/pintuans/faqipintuan/faqipintuan'
			});
		},
		gotiaozhuan(e) {
			uni.navigateTo({
				url: e.currentTarget.dataset.url
			});
		},

		tankuangguanbi() {
			this.tankuangisshows= false
		},

		tankuang() {
			this.tankuangisshows= true
		},

		jump_indexs(e) {
			console.log('sssssss');
			uni.reLaunch({
				url: '../index/index'
			});
		},

		jump_chaxun(e) {
			uni.reLaunch({
				url: '/pages/chaxun/chaxun'
			});
		},

		jump_pintuan(e) {
			uni.reLaunch({
				url: '/pages/pintuan/pintuan'
			});
		},

		jump_personal(e) {
			uni.reLaunch({
				url: '/pages/my/my'
			});
		},
		convertToaddress(data) {
			this.poi = data;
			console.log();
		},
		getBanner() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token')
			};
			request.get(`index.php?s=/api/sharp.index/banner&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					that.bannerList= res.data.data
				}
			});
		},
		getSharing() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token')
			};
			request.get(`index.php?s=/api/sharp.index/sharing&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					// console.log(res.data.data.list,7777)
					if (res.data.data.list.total > 0) {
						this.list = res.data.data.list.data;
					}
				}
			});
		},
		jumpzuo() {
			uni.navigateBack();
		},
		bannertiaozhuan(e) {
			console.log(e, 543);
			var type = e.currentTarget.dataset.type;
			var urlweb = e.currentTarget.dataset.url;
			if (type == 2) {
				uni.navigateTo({
					url: '/pages/webview/webview?' + 'url=' + urlweb
				});
			}
			uni.navigateTo({
				url: e.currentTarget.dataset.url
			});
		}
	}
};
</script>
<style>
@import './pintuan.css';
</style>
